package com.cos.lession.services.impl;

import com.cos.lession.dao.TemployeesMapper;
import com.cos.lession.entity.Temployees;
import com.cos.lession.services.TemployeesServices;
import com.cos.lession.util.MyBatisUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import java.util.List;

/**
 * @author: COS
 * @time: 2022/3/3 15:14
 * @description:
 */
public class TemployeesServicesImpl implements TemployeesServices {
    @Override
    public PageInfo<Temployees> getEmpByPage(int pageNum, int pages) {
        TemployeesMapper mapper = MyBatisUtils.getMapper(TemployeesMapper.class);
        //调用创建pageInfo pageHelper
        PageHelper.startPage(pageNum,pages);
        //必须是查询语句
        List<Temployees> all = mapper.getAll();
        //pageINfo
        PageInfo<Temployees> pi = new PageInfo<>(all);
        //关闭资源
        MyBatisUtils.close();
        return pi;
    }
}
